package cn.example.period;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class MyBeanPostProcessor implements BeanPostProcessor {

    public MyBeanPostProcessor() {
        System.out.println("Bean Post Processor 构造办法...");
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if ("demo".equals(beanName)) {
            System.out.println("BeanPostProcessor before initial...");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if ("demo".equals(beanName)) {
            System.out.println("BeanPostProcessor after initial...");
        }
        return bean;
    }
}
